blob: da318cfb6654291741ce069c1987c6c2fb2746a0 [file] [log] [blame]
Philipp Hanckeb7014f72017-02-27 13:24:201<!doctype html>
2<html>
3<head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>RTCPeerConnection setRemoteDescription tests</title>
6</head>
7<body>
8 <!-- These files are in place when executing on W3C. -->
9 <script src="/resources/testharness.js"></script>
10 <script src="/resources/testharnessreport.js"></script>
11 <script type="text/javascript">
Philipp Hancke86eb3cb2017-04-13 16:19:5012 // tests that ontrack is called and parses the msid information from the SDP and creates
Philipp Hancke0e550322017-05-03 13:46:4913 // the streams with matching identifiers.
Philipp Hanckeb7014f72017-02-27 13:24:2014 async_test(function(test) {
15 const sdp = 'v=0\r\n' +
16 'o=- 166855176514521964 2 IN IP4 127.0.0.1\r\n' +
17 's=-\r\n' +
18 't=0 0\r\n' +
19 'a=msid-semantic:WMS *\r\n' +
20 'm=audio 9 UDP/TLS/RTP/SAVPF 111\r\n' +
21 'c=IN IP4 0.0.0.0\r\n' +
22 'a=rtcp:9 IN IP4 0.0.0.0\r\n' +
23 'a=ice-ufrag:someufrag\r\n' +
24 'a=ice-pwd:somelongpwdwithenoughrandomness\r\n' +
25 'a=fingerprint:sha-256 8C:71:B3:8D:A5:38:FD:8F:A4:2E:A2:65:6C:86:52:BC:E0:6E:94:F2:9F:7C:4D:B5:DF:AF:AA:6F:44:90:8D:F4\r\n' +
26 'a=setup:actpass\r\n' +
27 'a=rtcp-mux\r\n' +
28 'a=mid:mid1\r\n' +
29 'a=sendonly\r\n' +
30 'a=rtpmap:111 opus/48000/2\r\n' +
31 'a=msid:stream1 track1\r\n' +
32 'a=ssrc:1001 cname:some\r\n';
33
34 var pc = new RTCPeerConnection(null);
35
Philipp Hancke86eb3cb2017-04-13 16:19:5036 pc.ontrack = test.step_func(function(event) {
Philipp Hancke86eb3cb2017-04-13 16:19:5037 assert_equals(event.streams.length, 1, 'the track belongs to one MediaStream');
38 assert_equals(event.streams[0].id, 'stream1', 'the stream name is parsed from the MSID line');
Philipp Hanckeb7014f72017-02-27 13:24:2039 test.done();
40 });
41
42 pc.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp}))
43 .catch(test.step_func(function(e) {
44 assert_unreached('Error ' + e.name + ': ' + e.message);
45 }));
Philipp Hancke0e550322017-05-03 13:46:4946 }, 'Triggers ontrack when called with a remote description and the MSID of the stream is is parsed.');
Soares Chena61973d2017-05-02 04:28:4847
48 promise_test(() => {
Soares Chen3be0b102017-05-02 04:37:5849 const pc = new RTCPeerConnection();
Soares Chena61973d2017-05-02 04:28:4850 return pc.setRemoteDescription(
51 {'type': 'offer', 'sdp': 'bogus'})
52 .then(() => {
53 assert_unreached('Bogus SDP should not be accepted');
54 })
55 .catch(e => {
56 assert_equals(e.name, 'InvalidAccessError');
57 });
58 }, 'Bogus SDP');
59
60 promise_test(() => {
Soares Chen3be0b102017-05-02 04:37:5861 const pc = new RTCPeerConnection();
Soares Chena61973d2017-05-02 04:28:4862 return pc.setRemoteDescription(
63 {'type': 'bogus', 'sdp': 'bogus'})
64 .then(() => {
65 assert_unreached('Bogus operation types should not be accepted');
66 })
67 .catch(e => {
68 assert_equals(e.name, 'TypeError');
69 });
70 }, 'Bogus Operation');
71
72 promise_test(() => {
Soares Chen3be0b102017-05-02 04:37:5873 const pc = new RTCPeerConnection();
Soares Chena61973d2017-05-02 04:28:4874 return pc.setRemoteDescription(
75 {'type': 'answer', 'sdp': 'bogus'})
76 .then(() => {
77 assert_unreached('Answer in "new" state should not be accepted');
78 })
79 .catch(e => {
80 assert_equals(e.name, 'InvalidStateError');
81 });
82 }, 'Bogus operation for state');
Philipp Hanckeb7014f72017-02-27 13:24:2083</script>
84
85</body>
86</html>